﻿using Furion.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
using ZeroAdmin.Application;
using ZeroAdmin.Application.Entity;
using ZeroAdmin.Core;

namespace ZeroAdmin.Web.Core;

/// <summary>
/// 角色服务
/// </summary>
/// <param name="service"></param>
[ApiDescriptionSettings(Name = "Role", Tag = "角色服务")]
public class RoleController(IRoleService service) : IDynamicApiController
{
    private readonly IRoleService _service = service;

    /// <summary>
    /// 查询全部角色
    /// </summary>
    /// <returns></returns>
    public async Task<List<Role>> GetList()
    {
        return await _service.GetList();
    }

    /// <summary>
    /// 查询角色列表
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task<PageListBase<Role>> GetPageList([FromQuery] QueryRoleInput input)
    {
        return await _service.GetPageList(input);
    }

    /// <summary>
    /// 新增角色
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task<long> AddRole(Role input)
    {
        return await _service.AddRole(input);
    }

    /// <summary>
    /// 更新角色
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task<long> UpdateRole(Role input)
    {
        return await _service.UpdateRole(input);
    }

    /// <summary>
    /// 删除角色
    /// </summary>
    /// <param name="RoleId"></param>
    /// <returns></returns>
    public async Task DeleteRole(long RoleId)
    {
        await _service.DeleteRole(RoleId);
    }
}
